package com.haoqizhe.kernel.activemq.entity;

import com.haoqizhe.kernel.activemq.common.ActivemqConstant;

import java.util.*;


/**
 *
 * 消息发送参数
 *
 * @author haoqizhe.li on 2017/6/20.
 */
public class SendParam {
    /**
     * DeliveryMode.NON_PERSISTENT=1:非持久 ;
     * DeliveryMode.PERSISTENT=2:持久
     */
    private int deliveryMode;
    /**
     * 消息优先级 0-9  数据越大 优先级越高
     */
    private int priority;
    /**
     * 消息有效时间 毫秒
     */
    private long timeToLive;
    /**
     * 是否支持事务管理
     */
    private boolean sessionTransacted;
    /**
     * 消息类型，true topic / false  queue
     */
    private boolean pubSubDomain;
    /**
     * 需要发送的消息 not null
     */
    private Object message;
    /**
     *  消息目的地名称 not null
     */
    private String destinationName;
    /**
     *  消息超时后的处理   0  不处理   1  重新发送
     */
    private String timeOverDo;
    /**
     *  消息超时后，选择重新发送时，重新发送的次数
     */
    private int resendTime;
    /**
     * 消息延迟投递  时间  毫秒
     */
    private long scheduledDelay;
    /**
     *  消息定时投递 时间 linux中corntab中的表达 式，基本顺序是"分(0-59) 时(0-23) 日(1-31) 月（1-12） 星期几(1-7) "
     *
     *   * * * * *
     */
    private String scheduledCron;
    /**
     *  消息重复投递次数，消息总共会发送（1+scheduledRepeat）次
     */
    private int scheduledRepeat;
    /**
     *  消息重复投递 间隔时间 毫秒
     */
    private long scheduledPeriod;
    /**
     * 自定义可拓展的消息头信息
     */
    private Map<String,Object> headers = new HashMap<String,Object>();
    /**
     * 消息转发的目的地名称
     */
    private String replyTo;
    /**
     * 消息转发的目的地类型，支持queue 和 topic两种类型
     */
    private String replyType;
    /**
     * 转发消息唯一标识，连接唯一标识
     */
    private String correlationId;

    /**
     * 消息目的地是否添加destination prefix
     */
    private boolean isDestinationPrefix;
    /**
     * 是否虚拟主题
     */
    private boolean isVirtualTopic;

    /**
     * 发送消息的系统名称
     */
    private String systemName;

    /**
     * 发送消息的系统ID
     */
    private String systemId;

    /**
     * 发送消息的系统认证密码
     */
    private String systemPassword;

    private String logId;

    public SendParam(String destinationName,Object message){
        this.destinationName = destinationName;
        this.message = message;

        this.pubSubDomain = true;
        this.isDestinationPrefix = true;
        this.deliveryMode = 2;
        this.priority = 4;
        this.timeToLive = 0L;
        this.sessionTransacted = false;
        this.timeOverDo = "0";
        this.resendTime = 0;
        this.scheduledDelay = -1L;
        this.scheduledCron = "";
        this.scheduledRepeat = 0;
        this.scheduledPeriod = -1L;
        this.replyTo = "";
        this.replyType = ActivemqConstant.DestinationType.QUEUE;
        this.isVirtualTopic = false;
        this.logId = UUID.randomUUID().toString();
    }

    public SendParam(String destinationName,Object message,int deliveryMode){
        this.destinationName = destinationName;
        this.message = message;
        this.deliveryMode = deliveryMode;

        this.pubSubDomain = true;
        this.isDestinationPrefix = true;
        this.priority = 4;
        this.timeToLive = 0L;
        this.sessionTransacted = false;
        this.timeOverDo = "0";
        this.resendTime = 0;
        this.scheduledDelay = -1L;
        this.scheduledCron = "";
        this.scheduledRepeat = 0;
        this.scheduledPeriod = -1L;
        this.replyTo = "";
        this.replyType = ActivemqConstant.DestinationType.QUEUE;
        this.isVirtualTopic = false;
        this.logId = UUID.randomUUID().toString();
    }

    public SendParam(boolean pubSubDomain,String destinationName,Object message){
        this.destinationName = destinationName;
        this.message = message;
        this.pubSubDomain = pubSubDomain;

        this.isDestinationPrefix = true;
        this.deliveryMode = 2;
        this.priority = 4;
        this.timeToLive = 0L;
        this.sessionTransacted = false;
        this.timeOverDo = "0";
        this.resendTime = 0;
        this.scheduledDelay = -1L;
        this.scheduledCron = "";
        this.scheduledRepeat = 0;
        this.scheduledPeriod = -1L;
        this.replyTo = "";
        this.replyType = ActivemqConstant.DestinationType.QUEUE;
        this.isVirtualTopic = false;
        this.logId = UUID.randomUUID().toString();
    }

    public SendParam(boolean pubSubDomain,String destinationName,Object message,int deliveryMode){
        this.destinationName = destinationName;
        this.message = message;
        this.pubSubDomain = pubSubDomain;
        this.deliveryMode = deliveryMode;

        this.isDestinationPrefix = true;
        this.priority = 4;
        this.timeToLive = 0L;
        this.sessionTransacted = false;
        this.timeOverDo = "0";
        this.resendTime = 0;
        this.scheduledDelay = -1L;
        this.scheduledCron = "";
        this.scheduledRepeat = 0;
        this.scheduledPeriod = -1L;
        this.replyTo = "";
        this.replyType = ActivemqConstant.DestinationType.QUEUE;
        this.isVirtualTopic = false;
        this.logId = UUID.randomUUID().toString();
    }

    public SendParam(String destinationName,Object message,boolean isVirtualTopic,int deliveryMode){
        this.destinationName = destinationName;
        this.message = message;
        this.isVirtualTopic = isVirtualTopic;
        this.deliveryMode = deliveryMode;
        this.pubSubDomain = true;

        this.priority = 4;
        this.timeToLive = 0L;
        this.sessionTransacted = false;
        this.timeOverDo = "0";
        this.resendTime = 0;
        this.scheduledDelay = -1L;
        this.scheduledCron = "";
        this.scheduledRepeat = 0;
        this.scheduledPeriod = -1L;
        this.replyTo = "";
        this.replyType = ActivemqConstant.DestinationType.QUEUE;
        this.isDestinationPrefix = true;
        this.logId = UUID.randomUUID().toString();
    }

    public SendParam(String destinationName,Object message,boolean isVirtualTopic){
        this.destinationName = destinationName;
        this.message = message;
        this.isVirtualTopic = isVirtualTopic;
        this.pubSubDomain = true;

        this.deliveryMode = 2;
        this.priority = 4;
        this.timeToLive = 0L;
        this.sessionTransacted = false;
        this.timeOverDo = "0";
        this.resendTime = 0;
        this.scheduledDelay = -1L;
        this.scheduledCron = "";
        this.scheduledRepeat = 0;
        this.scheduledPeriod = -1L;
        this.replyTo = "";
        this.replyType = ActivemqConstant.DestinationType.QUEUE;
        this.isDestinationPrefix = true;
        this.logId = UUID.randomUUID().toString();
    }

    public SendParam(){
        this.deliveryMode = 2;
        this.priority = 4;
        this.timeToLive = 0L;
        this.pubSubDomain = false;
        this.sessionTransacted = false;
        this.timeOverDo = "0";
        this.resendTime = 0;
        this.scheduledDelay = -1L;
        this.scheduledCron = "";
        this.scheduledRepeat = 0;
        this.scheduledPeriod = -1L;
        this.replyTo = "";
        this.replyType = ActivemqConstant.DestinationType.QUEUE;
        this.isDestinationPrefix = true;
        this.isVirtualTopic = false;
        this.logId = UUID.randomUUID().toString();
    }

    public int getDeliveryMode() {
        return deliveryMode;
    }

    /**
     * 设置消息
     * @param deliveryMode
     */
    public void setDeliveryMode(int deliveryMode) {
        this.deliveryMode = deliveryMode;
    }

    public int getPriority() {
        return priority;
    }

    public void setPriority(int priority) {
        this.priority = priority;
    }

    public long getTimeToLive() {
        return timeToLive;
    }

    public void setTimeToLive(long timeToLive) {
        this.timeToLive = timeToLive;
    }

    public boolean isSessionTransacted() {
        return sessionTransacted;
    }

    public void setSessionTransacted(boolean sessionTransacted) {
        this.sessionTransacted = sessionTransacted;
    }

    public boolean isPubSubDomain() {
        return pubSubDomain;
    }

    public void setPubSubDomain(boolean pubSubDomain) {
        this.pubSubDomain = pubSubDomain;
    }

    public Object getMessage() {
        return message;
    }

    public void setMessage(Object message) {
        this.message = message;
    }

    public String getDestinationName() {
        return destinationName;
    }

    public void setDestinationName(String destinationName) {
        this.destinationName = destinationName;
    }

    public String getTimeOverDo() {
        return timeOverDo;
    }

    public void setTimeOverDo(String timeOverDo) {
        this.timeOverDo = timeOverDo;
    }

    public int getResendTime() {
        return resendTime;
    }

    public void setResendTime(int resendTime) {
        this.resendTime = resendTime;
    }

    public long getScheduledDelay() {
        return scheduledDelay;
    }

    public void setScheduledDelay(long scheduledDelay) {
        this.scheduledDelay = scheduledDelay;
    }

    public String getScheduledCron() {
        return scheduledCron;
    }

    public void setScheduledCron(String scheduledCron) {
        this.scheduledCron = scheduledCron;
    }

    public int getScheduledRepeat() {
        return scheduledRepeat;
    }

    public void setScheduledRepeat(int scheduledRepeat) {
        this.scheduledRepeat = scheduledRepeat;
    }

    public long getScheduledPeriod() {
        return scheduledPeriod;
    }

    public void setScheduledPeriod(long scheduledPeriod) {
        this.scheduledPeriod = scheduledPeriod;
    }

    public Map<String, Object> getHeaders() {
        return headers;
    }

    public void setHeaders(Map<String, Object> headers) {
        this.headers = headers;
    }

    public String getReplyTo() {
        return replyTo;
    }

    public void setReplyTo(String replyTo) {
        this.replyTo = replyTo;
    }

    public String getReplyType() {
        return replyType;
    }

    public void setReplyType(String replyType) {
        this.replyType = replyType;
    }

    public String getCorrelationId() {
        return correlationId;
    }

    public void setCorrelationId(String correlationId) {
        this.correlationId = correlationId;
    }

    public boolean isDestinationPrefix() {
        return isDestinationPrefix;
    }

    public void setDestinationPrefix(boolean destinationPrefix) {
        isDestinationPrefix = destinationPrefix;
    }

    public boolean isVirtualTopic() {
        return isVirtualTopic;
    }

    public void setVirtualTopic(boolean virtualTopic) {
        isVirtualTopic = virtualTopic;
    }

    public String getSystemName() {
        return systemName;
    }

    public void setSystemName(String systemName) {
        this.systemName = systemName;
    }

    public String getSystemId() {
        return systemId;
    }

    public void setSystemId(String systemId) {
        this.systemId = systemId;
    }

    public String getSystemPassword() {
        return systemPassword;
    }

    public void setSystemPassword(String systemPassword) {
        this.systemPassword = systemPassword;
    }

    public String getLogId() {
        return logId;
    }

    public void setLogId(String logId) {
        this.logId = logId;
    }
}
